package com.lgt_enterprise_android.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.amap.api.services.core.PoiItem;
import com.lgt_enterprise_android.R;

import java.util.ArrayList;

public class PoiSearchAdapter  extends BaseAdapter {

    private Context mContext;

    private ArrayList<PoiItem> arrayList;

    public PoiSearchAdapter(Context _mContext, ArrayList<PoiItem> _mArray) {
        mContext=_mContext;
        arrayList=_mArray;
    }

    public void setData( ArrayList<PoiItem> _mArray){
        arrayList=_mArray;
    }

    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int pos, View convertView, ViewGroup viewGroup) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_poi, null);
            holder.txtTitle = (TextView) convertView.findViewById(R.id.txt_name);
            convertView.setTag(holder);
        } else {
            holder =  (ViewHolder)convertView.getTag();
        }

        PoiItem poiSearch =arrayList.get(pos);

        holder.txtTitle.setText(poiSearch.toString());

        return convertView;
    }

    public class ViewHolder {
        public TextView txtTitle;

    }
}
